Skip to content

Gh56 xmi serializer#87

Draft
antoineatstariongroup wants to merge 9 commits intodevelopmentfrom
GH56-xmi-serializer
Draft

Gh56 xmi serializer#87
antoineatstariongroup wants to merge 9 commits intodevelopmentfrom
GH56-xmi-serializer

Conversation

@antoineatstariongroup
Copy link
Collaborator

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the SysML2.NET code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

Fix #56

  • XMI Serializer via CodeGen
  • Created a validation test that assert that the Quantities.sysml can be deserialized and serialized again with the same content.

Note, for the validation test, some adjustement had to be done :

  • Align XMI namespace
  • discard some value
    • (%20 replaced by space, ignoring encoding and ignoring some explicit default value that are sometimes present)

…r-partial-for-element-template.hbs)

  - Replaced bool.Parse(), Enum.Parse(), int.Parse(), double.Parse() with TryParse() patterns
  - Replaced Guid.Parse() for href references with Guid.TryParse()
  - All failures now log warnings with property name, value, and element ID

  #2 - Missing default case in reader switch (core-xmi-reader-template.hbs)
  - Added default: case to both sync and async switch(xmiReader.LocalName) blocks
  - Logs warning with unexpected element name and line/position info
  - Calls xmiReader.Skip() / xmiReader.SkipAsync() to explicitly advance past unrecognized elements

  #3 - Writer instance caching (core-xmi-writer-facade-template.hbs)
  - Writer instances are now created once in the constructor (168 local variables)
  - Captured by lambda closures — no new allocations per element dispatch
  - Removed the loggerFactory field (no longer needed after construction)

  #6 - Silent reference loss logging (core-xmi-reader-partial-for-attribute-template.hbs)
  - Added else branches with logger.LogWarning() for both single and multi-reference Guid.TryParse failures

  #4 - FindNamespaceById optimization (Serializer.cs)
  - Replaced recursive FindNamespaceById() with BuildNamespaceIndex() that builds a Dictionary<Guid, INamespace> once before the loop
  - O(1) lookups instead of O(N) tree walks per source file

  #8 - DI for IXmiDataWriterFacade (Serializer.cs, tests)
  - Serializer constructor now accepts IXmiDataWriterFacade instead of creating XmiDataWriterFacade directly
  - Updated SerializerTestFixture.cs and RoundTripTestFixture.cs to pass facade

  #9 - Mutable elementOriginMap field (DeSerializer.cs)
  - Removed mutable IXmiElementOriginMap elementOriginMap instance field
  - Threaded elementOriginMap as a parameter through the entire method chain: DeSerialize → Read/ReadAsync → ResolveExternalReference/ResolveExternalReferenceAsync
  - DeSerializer instances are now safely reusable across calls with different origin maps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: implement xmi serializer

2 participants